package com.mallcai.bigdata.ladon.dpl.mapper.system;

import com.mallcai.bigdata.ladon.dpl.entity.system.RoleRlReport;
import com.mallcai.bigdata.ladon.dpl.mapper.system.provider.RoleRlReportSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface RoleRlReportMapper {
    @InsertProvider(type = RoleRlReportSqlProvider.class, method = "insert")
    public int insert(RoleRlReport rrr);

    @UpdateProvider(type = RoleRlReportSqlProvider.class, method = "update")
    public int update(RoleRlReport rrr);

    @UpdateProvider(type = RoleRlReportSqlProvider.class, method = "delete")
    public int delete(RoleRlReport rrr);

    @Delete({
            "DELETE FROM " + RoleRlReportSqlProvider.TB_ROLE_RL_REPORT + " WHERE archive = 0 AND role_id = #{roleId}"
    })
    public int deleteByRoleId(@Param("roleId") Long roleId);

    @Select({
            "SELECT report_id FROM  " + RoleRlReportSqlProvider.TB_ROLE_RL_REPORT + " WHERE archive = 0 AND role_id = #{roleId}"
    })
    public List<Long> getReportIdByRoleId(@Param("roleId") Long roleId);

    @SelectProvider(type = RoleRlReportSqlProvider.class, method = "getByRoleIds")
    public List<RoleRlReport> getByRoleIds(@Param("roleIds") List<Long> roleIds);

    @SelectProvider(type = RoleRlReportSqlProvider.class, method = "getByReportId")
    List<RoleRlReport> getByReportId(@Param("reportId") Long reportId);


}
